<?php

namespace app\admin\model\resource;

use think\Model;


class Teacher extends Model
{

    

    

    // 表名
    protected $name = 'teacher';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'type_text',
        'sex_data_text',
        'character_text',
        'education_text',
        'state_text',
        'payment_method_text',
        'status_text',
        'is_home_text'
    ];

    public function getIsTopList()
    {
        return [1=>'<span style="color:red">[置顶]</span> ',0=>''];
    }

    public function getIsHomeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_home']) ? $data['is_home'] : '');
        $list = $this->getIsTopList();
        return isset($list[$value]) ? $list[$value] : '';
    }
    
    public function getTypeList()
    {
        return [''=>'请选择','主带' => __('主带'), '辅教' => __('辅教'), '助教' => __('助教'), '摄影' => __('摄影'), '后勤' => __('后勤'), '其他' => __('其他')];
    }

    public function getSexDataList()
    {
        return ['男' => __('男'), '女' => __('女')];
    }

    public function getCharacterList()
    {
        return [''=>'请选择','老虎型：强势喜欢主导和控制' => __('老虎型：强势喜欢主导和控制'), '孔雀型：爱表现被人夸奖' => __('孔雀型：爱表现被人夸奖'), '老鹰型：理性思维不易被影响' => __('老鹰型：理性思维不易被影响'), '考拉型：老好人有求必应' => __('考拉型：老好人有求必应'), '鸽子型：值传递信息不轻易表面倾向' => __('鸽子型：值传递信息不轻易表面倾向'), '变色龙型：适应能力强，因环境而变' => __('变色龙型：适应能力强，因环境而变')];
    }

    public function getEducationList()
    {
        return [''=>'请选择','初中' => __('初中'), '高中' => __('高中'), '大专' => __('大专'), '大学' => __('大学'), '研究生' => __('研究生'), '博士' => __('博士'), '博士后' => __('博士后')];
    }

    public function getStateList()
    {
        return ['自有教练' => __('自有教练'), '外聘教练' => __('外聘教练')];
    }

    public function getPaymentMethodList()
    {
        return [''=>'请选择','支付宝' => __('支付宝'), '银行卡' => __('银行卡')];
    }

    public function getStatusList()
    {
        return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2')];
    }


    public function getTypeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
        $list = $this->getTypeList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getSexDataTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['sex_data']) ? $data['sex_data'] : '');
        $list = $this->getSexDataList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getCharacterTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['character']) ? $data['character'] : '');
        $list = $this->getCharacterList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getEducationTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['education']) ? $data['education'] : '');
        $list = $this->getEducationList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStateTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['state']) ? $data['state'] : '');
        $list = $this->getStateList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getPaymentMethodTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['payment_method']) ? $data['payment_method'] : '');
        $list = $this->getPaymentMethodList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function admin()
    {
        return $this->belongsTo('app\admin\model\Admin', 'principal_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
